package com.web.dao;

import com.github.pagehelper.Page;
import com.web.controller.web.WebSysLogController;
import com.web.entity.CompanyMarketDetail;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * @author FDjavaone
 */
public interface CompanyMarketDetailMapper {
    @Delete({
        "delete from t_company_market_detail",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into t_company_market_detail (content, detail, ",
        " from_num, name, description, ",
        " bal, phone, create_time, ",
        " modify_time)",
        " values (#{content,jdbcType=VARCHAR}, #{detail,jdbcType=VARCHAR}, ",
        " #{fromNum,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, ",
        " #{bal,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        " #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(CompanyMarketDetail record);

    @InsertProvider(type=CompanyMarketDetailSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(CompanyMarketDetail record);

    @Select({
        "select",
        " id, content, detail, from_num, name, description, bal, phone, create_time, modify_time",
        " from t_company_market_detail",
        " where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
        @Result(column="detail", property="detail", jdbcType=JdbcType.VARCHAR),
        @Result(column="from_num", property="fromNum", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="bal", property="bal", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    CompanyMarketDetail selectByPrimaryKey(Long id);

    @UpdateProvider(type=CompanyMarketDetailSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(CompanyMarketDetail record);

    @Update({
        "update t_company_market_detail",
        " set content = #{content,jdbcType=VARCHAR},",
          " detail = #{detail,jdbcType=VARCHAR},",
          " from_num = #{fromNum,jdbcType=VARCHAR},",
          " name = #{name,jdbcType=VARCHAR},",
          " description = #{description,jdbcType=VARCHAR},",
          " bal = #{bal,jdbcType=VARCHAR},",
          " phone = #{phone,jdbcType=VARCHAR},",
          " create_time = #{createTime,jdbcType=TIMESTAMP},",
          " modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        " where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(CompanyMarketDetail record);

    @SelectProvider(type = CompanyMarketDetailSqlProvider.class, method = "selectRecord")
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
            @Result(column="detail", property="detail", jdbcType=JdbcType.VARCHAR),
            @Result(column="from_num", property="fromNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
            @Result(column="bal", property="bal", jdbcType=JdbcType.VARCHAR),
            @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    Page<CompanyMarketDetail> selectRecord();

    @SelectProvider(type = CompanyMarketDetailSqlProvider.class, method = "selectAllCompanyMarketLogs")
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR),
            @Result(column="detail", property="detail", jdbcType=JdbcType.VARCHAR),
            @Result(column="from_num", property="fromNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="bal", property="bal", jdbcType=JdbcType.VARCHAR),
            @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
            @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    Page<CompanyMarketDetail> selectAllCompanyMarketLogs(WebSysLogController.DetailsColumns detailsColumns);
}